home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed fades ƒ / Slide fade reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  2.6 KB  |  92 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Slide fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define CorrectTime 1
  32. #define theWindowWidth (boundsRect.right-boundsRect.left)
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34.  
  35. pascal short SlideFadeReversed(Rect boundsRect, Pattern *thePattern);
  36.  
  37. /* Split the screen into 10 sections, then alternatively scroll left and right,
  38.    starting at the bottom section and working toward the top. */
  39.    
  40. pascal short SlideFadeReversed(Rect boundsRect, Pattern *thePattern)
  41. {
  42.     int                x, y;
  43.     Rect            dest;
  44.     Rect            scrollsource;
  45.     int                direction;
  46.     int                BoxSize, StripSize;
  47.     
  48.     BoxSize=theWindowWidth/25;
  49.     StripSize=theWindowHeight/10;
  50.     
  51.     direction = 0;
  52.     for(y = theWindowHeight-StripSize; y >= 0; y -= StripSize)
  53.     {
  54.         scrollsource = boundsRect;
  55.         scrollsource.top+=y;
  56.         scrollsource.bottom = scrollsource.top + StripSize;
  57.         
  58.         dest = scrollsource;
  59.         
  60.         if(direction == 0)
  61.         {
  62.             dest.right = dest.left + BoxSize;
  63.             
  64.             for(x = boundsRect.right - BoxSize; x >= boundsRect.left; x -= BoxSize)
  65.             {
  66.                 StartTiming();
  67.                 ScrollRect(&scrollsource, BoxSize, 0, 0L);
  68.                 FillRect(&dest, *thePattern);
  69.                 TimeCorrection(CorrectTime);
  70.             }
  71.             FillRect(&scrollsource, *thePattern);
  72.         }
  73.         else
  74.         {
  75.             dest.left = dest.right - BoxSize;
  76.             
  77.             for(x = boundsRect.left+BoxSize; x <= boundsRect.right; x += BoxSize)
  78.             {
  79.                 StartTiming();
  80.                 ScrollRect(&scrollsource, -BoxSize, 0, 0L);
  81.                 FillRect(&dest, *thePattern);
  82.                 TimeCorrection(CorrectTime);
  83.             }
  84.             FillRect(&scrollsource, *thePattern);
  85.         }
  86.         
  87.         direction = 1 - direction;
  88.     }
  89.     
  90.     return 0;
  91. }
  92.